3.8.19 \(\int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))^2}{(a+i a \tan (e+f x))^2} \, dx\) [719]

Optimal. Leaf size=97 \[ \frac {i B c^2 x}{a^2}-\frac {B c^2 \log (\cos (e+f x))}{a^2 f}-\frac {(i A-B) c^2}{a^2 f (i-\tan (e+f x))^2}+\frac {(A+3 i B) c^2}{a^2 f (i-\tan (e+f x))} \]

[Out]

I*B*c^2*x/a^2-B*c^2*ln(cos(f*x+e))/a^2/f-(I*A-B)*c^2/a^2/f/(I-tan(f*x+e))^2+(A+3*I*B)*c^2/a^2/f/(I-tan(f*x+e))

________________________________________________________________________________________

Rubi [A]
time = 0.11, antiderivative size = 97, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, integrand size = 41, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.049, Rules used = {3669, 78} \begin {gather*} \frac {c^2 (A+3 i B)}{a^2 f (-\tan (e+f x)+i)}-\frac {c^2 (-B+i A)}{a^2 f (-\tan (e+f x)+i)^2}-\frac {B c^2 \log (\cos (e+f x))}{a^2 f}+\frac {i B c^2 x}{a^2} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[((A + B*Tan[e + f*x])*(c - I*c*Tan[e + f*x])^2)/(a + I*a*Tan[e + f*x])^2,x]

[Out]

(I*B*c^2*x)/a^2 - (B*c^2*Log[Cos[e + f*x]])/(a^2*f) - ((I*A - B)*c^2)/(a^2*f*(I - Tan[e + f*x])^2) + ((A + (3*
I)*B)*c^2)/(a^2*f*(I - Tan[e + f*x]))

Rule 78

Int[((a_.) + (b_.)*(x_))*((c_) + (d_.)*(x_))^(n_.)*((e_.) + (f_.)*(x_))^(p_.), x_Symbol] :> Int[ExpandIntegran
d[(a + b*x)*(c + d*x)^n*(e + f*x)^p, x], x] /; FreeQ[{a, b, c, d, e, f, n}, x] && NeQ[b*c - a*d, 0] && ((ILtQ[
n, 0] && ILtQ[p, 0]) || EqQ[p, 1] || (IGtQ[p, 0] && ( !IntegerQ[n] || LeQ[9*p + 5*(n + 2), 0] || GeQ[n + p + 1
, 0] || (GeQ[n + p + 2, 0] && RationalQ[a, b, c, d, e, f]))))

Rule 3669

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a*(c/f), Subst[Int[(a + b*x)^(m - 1)*(c + d*x)^(n - 1)*(A + B*x), x
], x, Tan[e + f*x]], x] /; FreeQ[{a, b, c, d, e, f, A, B, m, n}, x] && EqQ[b*c + a*d, 0] && EqQ[a^2 + b^2, 0]

Rubi steps

\begin {align*} \int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))^2}{(a+i a \tan (e+f x))^2} \, dx &=\frac {(a c) \text {Subst}\left (\int \frac {(A+B x) (c-i c x)}{(a+i a x)^3} \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {(a c) \text {Subst}\left (\int \left (\frac {2 i (A+i B) c}{a^3 (-i+x)^3}+\frac {(A+3 i B) c}{a^3 (-i+x)^2}+\frac {B c}{a^3 (-i+x)}\right ) \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {i B c^2 x}{a^2}-\frac {B c^2 \log (\cos (e+f x))}{a^2 f}-\frac {(i A-B) c^2}{a^2 f (i-\tan (e+f x))^2}+\frac {(A+3 i B) c^2}{a^2 f (i-\tan (e+f x))}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 1.07, size = 140, normalized size = 1.44 \begin {gather*} \frac {c^2 \sec ^2(e+f x) \left (-4 B+\cos (2 (e+f x)) \left (-i A+B+2 B \log \left (\cos ^2(e+f x)\right )\right )-A \sin (2 (e+f x))-i B \sin (2 (e+f x))+2 i B \log \left (\cos ^2(e+f x)\right ) \sin (2 (e+f x))+4 B \text {ArcTan}(\tan (f x)) (-i \cos (2 (e+f x))+\sin (2 (e+f x)))\right )}{4 a^2 f (-i+\tan (e+f x))^2} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[((A + B*Tan[e + f*x])*(c - I*c*Tan[e + f*x])^2)/(a + I*a*Tan[e + f*x])^2,x]

[Out]

(c^2*Sec[e + f*x]^2*(-4*B + Cos[2*(e + f*x)]*((-I)*A + B + 2*B*Log[Cos[e + f*x]^2]) - A*Sin[2*(e + f*x)] - I*B
*Sin[2*(e + f*x)] + (2*I)*B*Log[Cos[e + f*x]^2]*Sin[2*(e + f*x)] + 4*B*ArcTan[Tan[f*x]]*((-I)*Cos[2*(e + f*x)]
 + Sin[2*(e + f*x)])))/(4*a^2*f*(-I + Tan[e + f*x])^2)

________________________________________________________________________________________

Maple [A]
time = 0.29, size = 64, normalized size = 0.66

method result size
derivativedivides \(\frac {c^{2} \left (B \ln \left (-i+\tan \left (f x +e \right )\right )-\frac {3 i B +A}{-i+\tan \left (f x +e \right )}-\frac {2 i A -2 B}{2 \left (-i+\tan \left (f x +e \right )\right )^{2}}\right )}{f \,a^{2}}\) \(64\)
default \(\frac {c^{2} \left (B \ln \left (-i+\tan \left (f x +e \right )\right )-\frac {3 i B +A}{-i+\tan \left (f x +e \right )}-\frac {2 i A -2 B}{2 \left (-i+\tan \left (f x +e \right )\right )^{2}}\right )}{f \,a^{2}}\) \(64\)
risch \(\frac {B \,c^{2} {\mathrm e}^{-2 i \left (f x +e \right )}}{a^{2} f}-\frac {c^{2} {\mathrm e}^{-4 i \left (f x +e \right )} B}{4 a^{2} f}+\frac {i c^{2} {\mathrm e}^{-4 i \left (f x +e \right )} A}{4 a^{2} f}+\frac {2 i B \,c^{2} x}{a^{2}}+\frac {2 i B \,c^{2} e}{a^{2} f}-\frac {B \,c^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}{a^{2} f}\) \(114\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))^2/(a+I*a*tan(f*x+e))^2,x,method=_RETURNVERBOSE)

[Out]

1/f*c^2/a^2*(B*ln(-I+tan(f*x+e))-(A+3*I*B)/(-I+tan(f*x+e))-1/2*(2*I*A-2*B)/(-I+tan(f*x+e))^2)

________________________________________________________________________________________

Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: RuntimeError} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))^2/(a+I*a*tan(f*x+e))^2,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative e
xponent.

________________________________________________________________________________________

Fricas [A]
time = 3.96, size = 93, normalized size = 0.96 \begin {gather*} \frac {{\left (8 i \, B c^{2} f x e^{\left (4 i \, f x + 4 i \, e\right )} - 4 \, B c^{2} e^{\left (4 i \, f x + 4 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + 4 \, B c^{2} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (i \, A - B\right )} c^{2}\right )} e^{\left (-4 i \, f x - 4 i \, e\right )}}{4 \, a^{2} f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))^2/(a+I*a*tan(f*x+e))^2,x, algorithm="fricas")

[Out]

1/4*(8*I*B*c^2*f*x*e^(4*I*f*x + 4*I*e) - 4*B*c^2*e^(4*I*f*x + 4*I*e)*log(e^(2*I*f*x + 2*I*e) + 1) + 4*B*c^2*e^
(2*I*f*x + 2*I*e) + (I*A - B)*c^2)*e^(-4*I*f*x - 4*I*e)/(a^2*f)

________________________________________________________________________________________

Sympy [A]
time = 0.33, size = 206, normalized size = 2.12 \begin {gather*} \frac {2 i B c^{2} x}{a^{2}} - \frac {B c^{2} \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{a^{2} f} + \begin {cases} \frac {\left (4 B a^{2} c^{2} f e^{4 i e} e^{- 2 i f x} + \left (i A a^{2} c^{2} f e^{2 i e} - B a^{2} c^{2} f e^{2 i e}\right ) e^{- 4 i f x}\right ) e^{- 6 i e}}{4 a^{4} f^{2}} & \text {for}\: a^{4} f^{2} e^{6 i e} \neq 0 \\x \left (- \frac {2 i B c^{2}}{a^{2}} + \frac {\left (A c^{2} + 2 i B c^{2} e^{4 i e} - 2 i B c^{2} e^{2 i e} + i B c^{2}\right ) e^{- 4 i e}}{a^{2}}\right ) & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))**2/(a+I*a*tan(f*x+e))**2,x)

[Out]

2*I*B*c**2*x/a**2 - B*c**2*log(exp(2*I*f*x) + exp(-2*I*e))/(a**2*f) + Piecewise(((4*B*a**2*c**2*f*exp(4*I*e)*e
xp(-2*I*f*x) + (I*A*a**2*c**2*f*exp(2*I*e) - B*a**2*c**2*f*exp(2*I*e))*exp(-4*I*f*x))*exp(-6*I*e)/(4*a**4*f**2
), Ne(a**4*f**2*exp(6*I*e), 0)), (x*(-2*I*B*c**2/a**2 + (A*c**2 + 2*I*B*c**2*exp(4*I*e) - 2*I*B*c**2*exp(2*I*e
) + I*B*c**2)*exp(-4*I*e)/a**2), True))

________________________________________________________________________________________

Giac [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 201 vs. \(2 (87) = 174\).
time = 0.69, size = 201, normalized size = 2.07 \begin {gather*} -\frac {\frac {6 \, B c^{2} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 1\right )}{a^{2}} - \frac {12 \, B c^{2} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - i\right )}{a^{2}} + \frac {6 \, B c^{2} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 1\right )}{a^{2}} + \frac {25 \, B c^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} + 12 \, A c^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} - 112 i \, B c^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} - 198 \, B c^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 12 \, A c^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 112 i \, B c^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 25 \, B c^{2}}{a^{2} {\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - i\right )}^{4}}}{6 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))^2/(a+I*a*tan(f*x+e))^2,x, algorithm="giac")

[Out]

-1/6*(6*B*c^2*log(tan(1/2*f*x + 1/2*e) + 1)/a^2 - 12*B*c^2*log(tan(1/2*f*x + 1/2*e) - I)/a^2 + 6*B*c^2*log(tan
(1/2*f*x + 1/2*e) - 1)/a^2 + (25*B*c^2*tan(1/2*f*x + 1/2*e)^4 + 12*A*c^2*tan(1/2*f*x + 1/2*e)^3 - 112*I*B*c^2*
tan(1/2*f*x + 1/2*e)^3 - 198*B*c^2*tan(1/2*f*x + 1/2*e)^2 - 12*A*c^2*tan(1/2*f*x + 1/2*e) + 112*I*B*c^2*tan(1/
2*f*x + 1/2*e) + 25*B*c^2)/(a^2*(tan(1/2*f*x + 1/2*e) - I)^4))/f

________________________________________________________________________________________

Mupad [B]
time = 8.51, size = 104, normalized size = 1.07 \begin {gather*} \frac {c^2\,\left (2\,B+A\,\mathrm {tan}\left (e+f\,x\right )+B\,\mathrm {tan}\left (e+f\,x\right )\,3{}\mathrm {i}+B\,\ln \left (-1-\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )-B\,{\mathrm {tan}\left (e+f\,x\right )}^2\,\ln \left (-1-\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )+B\,\mathrm {tan}\left (e+f\,x\right )\,\ln \left (-1-\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )\,2{}\mathrm {i}\right )}{a^2\,f\,{\left (1+\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )}^2} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(((A + B*tan(e + f*x))*(c - c*tan(e + f*x)*1i)^2)/(a + a*tan(e + f*x)*1i)^2,x)

[Out]

(c^2*(2*B + A*tan(e + f*x) + B*tan(e + f*x)*3i + B*log(- tan(e + f*x)*1i - 1) - B*tan(e + f*x)^2*log(- tan(e +
 f*x)*1i - 1) + B*tan(e + f*x)*log(- tan(e + f*x)*1i - 1)*2i))/(a^2*f*(tan(e + f*x)*1i + 1)^2)

________________________________________________________________________________________